<template>
	<view class="bg-white radius padding-xsm margin-bottom-sm" style="width: 308rpx;" @click="openDetails(item.id,item.secondCategoryId)">
		<image :src="item.imageUrl" class="radius" style="width: 308rpx; height: 308rpx;" mode="aspectFit"></image>
		<view class="padding-tb-xs" style="line-height: 1.2em;">
			<text class="text-sm color-black">{{item.productName}}</text>
		</view>
		<view class="flex-direction-row align-center justify-between margin-top-xs">
			<view class="flex-direction-row align-end">
				<text class="text-xs text-bold color-df">￥</text>
				<text class="text-xl color-df text-bold" style="margin-bottom: -4rpx;">{{Math.floor(item.price)}}</text>
				<text class="text-xsm color-df">.{{priceSet(item.price)}}</text>
			</view>
			<text class="text-xsl iconfont color-df color-df">&#xe664;</text>
		</view>
	</view>
</template>

<script>
	export default {
		name:"goods",
		props: {
			item: {
				type: Object,
				default: {}
			},
			type: {
				type: Number,
				default: -1
			}
		},
		data() {
			return {
				
			};
		},
		methods:{
			openDetails(id,secondCategoryId){
				let url;
				if(this.type != -1){
					url = '/pages/mall/goods-market?id='+id+'&type='+this.type
				}else{
					url = '/pages/mall/goods?id='+id
				}
				uni.navigateTo({
					url: url
				});
			},
			priceSet(price){
				// console.log('price: ',price);
				let priceArr = (price+'').split('.');
				// console.log('priceArr: ',priceArr);
				if(priceArr[1]){
					let newPrice = priceArr[1].substring(0,2)
					return newPrice.length === 2 ? newPrice : newPrice * 10
				}else{
					return '00'
				}
			}
		}
	}
</script>

<style>

</style>